//
//  TFCenteredImage.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/4/30.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFCenteredImage: UIButton {
    //下划线
    @objc public let Underline = UIView()
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.Underline.isHidden = true
        self.addSubview(self.Underline)
        self.Underline.backgroundColor = UIColor(red: 0.25, green: 0.52, blue: 0.89, alpha: 1)
      
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        
        let imageWidth = self.frame.size.width * (140.0/260.0)
        
        let imageY = (self.frame.size.height - imageWidth)/2
        let imageX = (self.frame.size.width - imageWidth)/2
        
        self.imageView!.frame = CGRect(x: imageX, y: imageY, width: imageWidth, height: imageWidth)
        
        
        self.Underline.frame = CGRect(x: 0, y: self.frame.size.height - 2, width: self.frame.size.width, height: 2)

        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
